Velocity of Moving Object Under Decelerating Force

  • PROGRAM: Velocity of moving object under decelerating force
  • CREATED: 4/14/2018

In [1]:
#Import packages.
import numpy as np
import matplotlib.pylab as plt
%matplotlib notebook

In [2]:
#Set folder to save images in.
import os
#os.chdir('Folder/Address/In/Here')

In [3]:
#Rename the function 'figure' from the 'plt' library (a.k.a. the 'matplotlib.pylab' library) to make it more convenient to use.
fig = plt.figure()

#Set up axes.
ax = fig.add_subplot(1, 1, 1)



In [4]:
#Define the parameters in the problem. This way, they are located in one place in the code and can be easily changed to test different values.
k = 2
b = 3
v_0 = 15

C = v_0**2 / (v_0**2 + b**2)

#Pretend to plot the function as a smooth curve by plotting a thousand points close together.
t_f = 10
t = np.linspace(0, t_f, 1000)
#Above creates 1000 points at evenly-spaced locations between 0 and some final time, t_f.

#Define the function.
#Assume v > 0. (An 'opposite' graph of the same shape would appear if a minus sign was added. One can try this.)
v = ( abs(b) * C * np.exp( -b**2 * k * t ) ) / np.sqrt( 1 - C * np.exp(-2 * b**2 * k * t))

#Plot the function.
ax.plot(t, v, 'b-', label = 'Velocity')

#Label the plot.
fig.suptitle('Velocity of Object with Decelerating Force $F = -mk(v^3 + a^2v)$')
ax.set_xlabel('Time, t (seconds)')
ax.set_ylabel('Velocity, v ($\\frac{meters}{s}$)')

ax.legend(loc = 'upper right', fancybox = False, shadow = False)


Out[4]:
<matplotlib.legend.Legend at 0x118359d30>

In [5]:
#Save figure by inserting a filename below.
#plt.savefig()

Notes

  • Make sure that comments are as concise as possible, while being as helpful as possible.
  • Add observations about important values.
    • If $v_0 = 0$, $v(t) = 0$ for all $t$. If initial velocity is 0, the object never moves.
    • Increasing $k$ or $a$ makes the force against the particle greater, and it approaches 0 faster.
    • The particle's velocity never reaches 0, but approaches 0 as time approaches infinity.